package com.example.testapiauto.testCase.openApi;

import com.alibaba.fastjson.JSONObject;
import com.example.testapiauto.app.serviceImp.myAssertImp;
import com.example.testapiauto.modules.testCase.utils.HttpClient;
import com.example.testapiauto.yuxiang.authorization;
import com.example.testapiauto.yuxiang.resultsUtils;
import io.qameta.allure.*;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * TODO
 *
 * @author yuxiang
 * @version 1.0
 * @date 2021/4/23 15:28
 */

@Epic("系统日志")
@Feature("获取")
public class systemLog {

    private static final Logger logger = LogManager.getLogger(systemLog.class);
    String testUrl = resultsUtils.TestUrl;
    String POSTToken = authorization.TestEnvAuthenticationPOSTNull();
    myAssertImp myassertimp = new myAssertImp();



    @Story("获取系统日志")
    @Test(description = "正常查看")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_1() {
        Object[] expect = new Object[2];
        expect[0] = "20000";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/system/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\": 575941366129642,\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\": " +
                "\"detailsssss\",\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：1，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，accountId为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_2() {
        Object[] expect = new Object[2];
        expect[0] = "400";
        expect[1] = "Bad Request";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\": ,\"account\": \"zuisheng\",\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\": " +
                "\"detailsssss\",\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：2，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("status");
        act.get("error");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.status";
        JsonPach[1] = "$.error";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("status"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，accountId为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_3() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "参数异常,请检查参数:account不能为空";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\": null,\"account\": \"zuisheng\",\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\": " +
                "\"detailsssss\",\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：3，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("subMsg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.subMsg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，accountId为错误的")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_4() {
        Object[] expect = new Object[2];
        expect[0] = "400";
        expect[1] = "Bad Request";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\": 57594136612991z,\"account\": \"zuisheng\",\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\":                  \"detailsssss\",\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：4，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("status");
        act.get("error");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.status";
        JsonPach[1] = "$.error";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("status"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，accountId为错误的")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_5() {
        Object[] expect = new Object[2];
        expect[0] = "400";
        expect[1] = "Bad Request";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\": 575941366129912,\"account\": \"zuisheng\",\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\":                  \"detailsssss\",\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：5，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("status");
        act.get("error");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.status";
        JsonPach[1] = "$.error";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("status"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，account为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_6() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "参数异常,请检查参数:account不能为空";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"account\":\"\",\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\":\"detailsssss\",\"extInfos\": \"xd%D\",                \"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：6，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("subMsg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.subMsg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }


    @Story("获取审计日志")
    @Test(description = "异常查看，account为错误的")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_7() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "business exception";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"account\":\"zz\",\"ip\": \"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：7，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，IP为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_8() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "business exception";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\": \"\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：8，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，IP为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_9() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "business exception";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":null,\"module\": \"\",\"level\": \"\",\"title\": \"测试\",\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：9，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，IP为256")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_10() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "business exception";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.256\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：10，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "正常查看，module为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_11() {
        Object[] expect = new Object[2];
        expect[0] = "20000";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\": \"\",\"level\": \"\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：11，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，module为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_12() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":null,\"level\": \"\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：12，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，module为错误的")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_13() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"假斯文\",\"level\": \"\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：13，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "正常查看，level为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_14() {
        Object[] expect = new Object[2];
        expect[0] = "20000";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：14，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，level为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_15() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": null,\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：15，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，level为错误的")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_16() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"假斯文\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：16，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，level为特殊字符")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_17() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"！@#￥\",\"title\": \"测试\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：17，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，title为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_18() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\": null," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：18，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，title为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_19() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：19，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，title为错误的")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_20() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"123\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：20，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，title为特殊字符")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_21() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"！@#\"," +
                "\"detail\":\"detailsssss\"," +
                "\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：21，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，detail为空")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_22() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"测试\"," +
                "\"detail\":\"\",\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：22，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，detail为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_23() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"测试\"," +
                "\"detail\":null,\"extInfos\": \"xd%D\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：23，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，extInfos为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_24() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"测试\"," +
                "\"detail\":\"详情\",\"extInfos\": null,\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：24，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，extInfos为特殊字符")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_25() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"测试\"," +
                "\"detail\":\"详情\",\"extInfos\": \"！@#\",\"operatorDate\": \"\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：25，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，operatorDate为null")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_26() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"测试\"," +
                "\"detail\":\"详情\",\"extInfos\": \"\",\"operatorDate\": null}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：26，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }

    @Story("获取审计日志")
    @Test(description = "异常查看，operatorDate为特殊字符")
    @Description("验证是否能查看")
    @Owner("醉生")
    @Step("输入 url:" + resultsUtils.TestUrl)
    @Link(resultsUtils.TestUrl)
    @Link(name = "测试地址", type = "接口测试")
    @Severity(SeverityLevel.NORMAL)
    public void case_27() {
        Object[] expect = new Object[2];
        expect[0] = "20002";
        expect[1] = "success";
        String url = testUrl + "/openApi/manager/v1/log/create";
        logger.info("请求url：" + url);
        Map<String, Object> headers = new HashMap<>();
        headers.put("Content-Type","application/json");
        headers.put("Authorization",POSTToken);
        logger.info("请求头："+headers);
        String body = "{\"accountId\":575941366129913,\"ip\":\"127.0.0.1\",\"module\":\"\",\"level\": \"\",\"title\":\"测试\"," +
                "\"detail\":\"详情\",\"extInfos\": \"\",\"operatorDate\": \"！@#\"}";
        logger.info("请求参数："+body);
        String response = HttpClient.doPost_Json(body, url, headers);
        logger.info("用例数：27，响应结果：" + response);
        JSONObject act = JSONObject.parseObject(response);
        act.get("code");
        act.get("msg");
        String[] JsonPach = new String[2];
        JsonPach[0] = "$.code";
        JsonPach[1] = "$.msg";
        boolean ResponseAssert = myassertimp.AssertByJsonPath(expect, act, JsonPach);
        logger.info("响应断言：" + ResponseAssert);
        Assert.assertEquals(expect[0], act.getString("code"));
    }
}
